package com.tiancheng.trade.merchant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 进件异常状态
 */
@Getter
@AllArgsConstructor
public enum ApplyErrorStatusEnums {
    ING("0","待审核"),
    ACCOUNT_VERIFY_ERROR("1","对公账户待验证或异常"),
    CERTIFICATE_FILE_ERROR("2","资料验证失败"),
    ACCOUNT_FREEZE_ERROR("3","账户冻结"),
    FAIL("4","进件失败（需要重新发起流程了）"),
    UNKNOWN_ERROR("9","未知错误"),
    ;

    private final String code;
    private final String desc;

    /**
     * 根据code获取具体枚举，一般switch中使用
     *
     * @param code
     * @return
     */
    public static ApplyErrorStatusEnums getByCode(String code) {
        return Arrays.stream(values()).filter(d -> Objects.equals(d.getCode(), code)).findFirst().orElse(null);
    }
}
